home *** CD-ROM | disk | FTP | other *** search
- /*
- single connection handler for the ds service, see ds.rexx
- */
-
- call initGlobal
- call getSocket
- call logConnection
- call handle
-
- exit
- /***************************************************************************/
- initGlobal: procedure expose global.
- global.prg=ProgramName()
- call SysLogCtl(global.prg)
- global.verbose=GetVar("VERBOSE","LOCAL")
- if global.verbose="" then global.verbose=0
- return
- /***************************************************************************/
- getSocket: procedure expose global.
- global.sock=LastSocket()
- if global.sock==-1 then do
- call EasyRequest(global.prg "can only be started by ds with RXSCall",global.prg)
- exit
- end
- return
- /***************************************************************************/
- handle: procedure expose global.
- sel.read.0=global.sock
- res = WaitSelect("SEL",10,0,2**12)
- if res<0 then call err "err wait %m"
- if res=0 then call err "timeout ("global.peer")"
- if recv2(global.sock,"BUFF",256)<0 then call err "error recv %m"
- date=formatdate(,"%a, %d %b %Y %X")
- if send(global.sock,date)<0 then call err "error send %m"
- return
- /***************************************************************************/
- err: procedure expose global.
- parse arg msg
- if global.verbose then call SysLog(msg,"ERR")
- exit
- /***************************************************************************/
- info: procedure expose global.
- parse arg msg
- if global.verbose then call SysLog(msg,"INFO")
- return
- /***************************************************************************/
- logConnection: procedure expose global.
- if GetPeerName(global.sock,"GLOBAL")<0 then call err "can't get peer info %m"
- global.peer="<"global.addrAddr":"global.addrPort">"
- if global.verbose then call info "connection from" global.peer
- return
- /***************************************************************************/
-